<template>
	<view class="moreLive">
		<c-layout>
			<c-navigation-bar slot="head" :bgColor="true" :title="$t('liveBar.more_live')" leftIconBorder="#fff"></c-navigation-bar>
		<view class="mainTitle">
			{{$t('liveBar.viewing_records')}}
		</view>
		<view class="record_row" v-if="LiveRecord.length!=0">
			<view class="record_rowList" v-for="(item,index) in LiveRecord" :key="index" @click="ToLiveRoom(item)">
				<image class="avatar" :src="$u.file.getMedieUrl(item.anchorAvatar)" mode=""></image>
				<image class="record_rowImg1" src="../../static/images/liveBar/close_b.png" @click.stop="delateItem(index,item)" mode=""></image>
				<image class="record_rowImg2" src="../../static/images/video/play.png" mode=""></image>
				<text class="liveName">{{item.liveStatus==2?item.anchorName:$t('liveBar.not_start')}}</text>
			</view>
		</view>
		<view class="noRecord" v-else>
			<text style="text-align: center;">{{$t('liveBar.history')}}</text>
		</view>
		<view class="mainTitle">
			{{$t('liveBar.liveRecommendation')}}
		</view>
		<view class="record_col">
			<view class="record_colList" v-for="(item,index) in LivingList" :key="index" @click="ToLiveRoom(item)">
				<view class="record_colContent">
					<image class="record_colImg" :src="$u.file.getMedieUrl(item.livesImage)" mode="aspectFill"></image>
					<view class="record_colIntro">
						<text class="liveName">{{item.nickName}}</text>   
						<view class="record_colHot">
							<image class="fire" src="../../static/images/video/fire.png" mode=""></image>
							<text class="record_colCount">{{item.fans}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		</c-layout>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				LivingList: [],
				LiveRecord:[],
			}
		},
		onLoad() {
			this.$u.post("/app/anchor/lives/room/getAnchorLivesRoom",{liveStatus:2}).then(res => {
				console.log('直播间列表', res.data.records)
				this.LivingList = res.data.records
			})
			this.$u.post("/app/liveWatchRecord/selectAll",{pageSize:20,pageNum:1}).then(res => {
				console.log('观看记录', res.data.records)
				this.LiveRecord = res.data.records
			})
		},
		methods: {
			back(){
				uni.navigateBack(1)
			},
			//进入直播间
			ToLiveRoom(data){
				if(data.liveStatus==2){
					uni.publicJS.intoPlayer({...data,userName:data.nickName})
				}else{
					this.$refs.uToast.show({
						title: this.$t('media.noOpen'),
						type: 'default',
					})
				}
			},
			//删除观看记录
			delateItem(idx,data){
				console.log(data.id)
				this.$u.post(`/app/liveWatchRecord/del/${data.id}`).then(res=>{
					if(res.code==200){
						this.LiveRecord.splice(idx,1)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.moreLive {
		.navBar {
			padding: 0 40rpx;
			display: flex;
			justify-content: space-between;
			margin-top: 20rpx;
			.title {
				width: 138rpx;
				height: 44rpx;
				font-size: 34rpx;
				font-weight: 400;
				color: #000000;
				line-height: 44rpx;
			}
		}
		.mainTitle {
			padding: 0 40rpx;
			height: 56rpx;
			font-size: 36rpx;
			font-weight: 400;
			color: #212121;
			line-height: 56rpx;
			margin-top: 32rpx;
		}
		.noRecord{
			width: 100%;
			height: 120rpx;
			line-height: 120rpx;
			text-align: center;
		}
		.record_row {
			display: flex;
			overflow: auto;
			margin-top: 40rpx;
			padding: 0 31rpx;
			.record_rowList {
				flex-shrink: 0;
				width: 200rpx;
				height: 200rpx;
				border-radius: 20rpx;
				opacity: 1;
				margin: 0 10rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
				position: relative;
				padding-bottom: 12rpx;
				.avatar{
					width: 100%;
					height: 100%;
					position: absolute;
					border-radius: 20rpx;
				}
				.liveName {
					height: 34rpx;
					font-size: 24rpx;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 34rpx;
					z-index: 1;
					text-align: center;
				}
				.record_rowImg1 {
					position: relative;
					left: 70rpx;
					width: 32rpx;
					height: 32rpx;
					margin-top: 14rpx;
				}
				.record_rowImg2 {
					width: 40rpx;
					height: 40rpx;
				}
			}
		}
		.record_col {
			padding: 0 31rpx;
			margin-top: 32rpx;
			display: flex;
			flex-wrap: wrap;
			.record_colList {
				width: 326rpx;
				height: 364rpx;
				border-radius: 24rpx;
				opacity: 1;
				margin: 20rpx 9rpx 0;
				.record_colContent {
					width: 100%;
					height: 100%;
					display: flex;
					justify-content: space-between;
					position: relative;
					.record_colImg {
						border-radius: 24rpx;
						width: 100%;
						height: 100%;
					}
					.record_colIntro {
						height: 100%;
						width: 100%;
						position: absolute;
						padding: 22rpx 20rpx;
						display: flex;
						align-items: flex-end;
						.liveName {
							width: 72rpx;
							height: 34rpx;
							font-size: 24rpx;
							font-weight: 400;
							color: #FFFFFF;
							line-height: 34rpx;
							flex: 1;
							text-align: center;
						}
						.record_colHot {
							// margin-top: 100%;
							text-align: center;
							width: 120rpx;
							height: 50rpx;
							background: rgba(0, 0, 0, 0.55);
							border-radius: 60rpx;
							opacity: 1;
							display: flex;
							justify-content: space-evenly;
							align-items: center;
							.fire{
								width: 28rpx;
								height: 30rpx;
							}
							.record_colCount {
								width: 40rpx;
								height: 34rpx;
								font-size: 24rpx;
								font-weight: 400;
								color: #FFFFFF;
								line-height: 34rpx;
							}
						}
					}

				}

			}
		}
	}
</style>